$tbody.on('click',function(e){
    const target = e.target
    if($(target).is(".btn-edit")){
        $(target).parent().parent().addClass('edit')
        var sp = $(target).parent().siblings().children(':first-child')
        var inp = $(target).parent().siblings().children(':last-child')
        sp.each((index)=>{
            sp[index].value = inp[index].innerHTML
        })
    }else if($(target).is(".btn-ok")){
        var id = $(target).parent().parent().attr('data-id')
        var name = $(target).parent().siblings().children(':last-child')[0].value
        var price = $(target).parent().siblings().children(':last-child')[1].value
        var num = $(target).parent().siblings().children(':last-child')[2].value
        $.ajax({
            url:'./api/shop/edit.php',
            data:{id,name,price,num},
            success: resp => {
                console.log(resp)
                if (resp.code === 200) {
                    $(target).parent().parent().removeClass('edit')
                    var sp = $(target).parent().siblings().children(':first-child')
                    var inp = $(target).parent().siblings().children(':last-child')
                    sp.each((i) => {
                        sp[i].innerHTML = inp[i].value
                    })
                }
            },
            dataType: 'json'
        })
    } else if ($(target).is('.btn-cancel')) {
        $(target).parent().parent().removeClass('edit')
    }
})